﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class WebControl_MessageInfo : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string strMesId = Request.QueryString["mesId"];
            if (!Common.Help.IsNumber(strMesId))
            {
                Common.Jscript.Alert("参数错误！");
                return;
            }
            int mesId = int.Parse(strMesId);
            BLL.MessageBLL bll = new BLL.MessageBLL();
            Model.SessionUser sUser = BaseLogin.getSessionNode(HttpContext.Current);
            Model.message model = bll.GetModel(sUser.uid, mesId);
            if (model == null)
            {
                Common.Jscript.Alert("参数错误！");
                return;
            }
            this.labContent.Text = model.content;
            this.labCreateTime.Text = model.createTime.ToString();
            this.labCreator.Text = model.creatorUserName;
            this.labTitle.Text = model.title;
            if (model.state == 0)
            {
                bll.SetRead(sUser.uid, mesId);
            }
        }

    }
    protected void btnClick_Click(object sender, EventArgs e)
    {
        string strMesId = Request.QueryString["mesId"];
        if (!Common.Help.IsNumber(strMesId))
        {
            Common.Jscript.Alert("参数错误！");
            return;
        }
        int mesId = int.Parse(strMesId);
        BLL.MessageBLL bll = new BLL.MessageBLL();
        Model.SessionUser sUser = BaseLogin.getSessionNode(HttpContext.Current);
        if (bll.Delete(sUser.uid, mesId))
        {
            Response.Redirect("Message.aspx");
        }
        else
        {
            Common.Jscript.Alert("参数错误！");
            return;
        }
    }
}
